import time

import pymysql

conn = pymysql.connect(host="121.4.69.146", user='root', password='xhhg@2020', port=3306, db="big_data",
                       use_unicode=True, charset='utf8')
cur = conn.cursor()

sql = 'SELECT application_number FROM patent_table WHERE patent_type IS NULL'
cur.execute(sql)
li = cur.fetchall()
count = 0
for sqh in li:
    patent_type = ''
    application_number = sqh[0]
    if application_number[4] == '1':
        patent_type = '发明专利'
    elif application_number[4] == '2':
        patent_type = '实用新型'
    elif application_number[4] == '3':
        patent_type = '外观设计'
    print(application_number, patent_type)
    count += 1
    sql = f"UPDATE patent_table set patent_type='{patent_type}' WHERE application_number = '{application_number}'"
    cur.execute(sql)
    conn.commit()
    print("提交完成")




